package com.xyh.jvmDemo;

import java.io.FileNotFoundException;
import java.net.URL;
import java.net.URLClassLoader;

/**
 * @version v1.0
 * @类描述：
 * @项目名称：
 * @包名： com.xyh.jvmDemo
 * @类名称：MyclassLoader
 * @创建人：YIHANG.XU
 * @创建时间：2020/5/2710:54 上午
 * @修改人：YIHANG.XU
 * @修改时间：2020/5/2710:54 上午
 * @修改备注：
 * @Copyright
 */
public class MyclassLoader extends ClassLoader {
    @Override
    protected Class<?> findClass(String name) throws ClassNotFoundException {

        byte[] classFrom = getClassFrom(name);
        if (classFrom != null) {
            return defineClass(name, classFrom, 0, classFrom.length);
        } else {
            try {
                throw new FileNotFoundException();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
        return super.findClass(name);
    }

    private byte[] getClassFrom(String name) {
        return null;
    }

    static final class MyclassLoader1 extends URLClassLoader {

        public MyclassLoader1(URL[] urls) {
            super(urls);
        }
    }
}
